package com.ys.io.p2数据流读写基本数据类型;

import java.util.Objects;

/**
 * 描述:用来测试数据的读与写
 *
 * @author CodeYang
 * @version 2021/1/2 21:22
 */
public class Student {

    private int id;

    private String stuName;
    /**
     * 学生成绩
     */
    private double stuScore;
    /**
     * 学生性别
     */
    private char stuSex;
    /**
     * 是否吸烟
     */
    private boolean smoking;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getStuName() {
        return stuName;
    }

    public void setStuName(String stuName) {
        this.stuName = stuName;
    }

    public double getStuScore() {
        return stuScore;
    }

    public void setStuScore(double stuScore) {
        this.stuScore = stuScore;
    }

    public char getStuSex() {
        return stuSex;
    }

    public void setStuSex(char stuSex) {
        this.stuSex = stuSex;
    }

    public boolean isSmoking() {
        return smoking;
    }

    public void setSmoking(boolean smoking) {
        this.smoking = smoking;
    }

    public Student(int id, String stuName, double stuScore, char stuSex, boolean smoking) {
        this.id = id;
        this.stuName = stuName;
        this.stuScore = stuScore;
        this.stuSex = stuSex;
        this.smoking = smoking;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return id == student.id &&
                Double.compare(student.stuScore, stuScore) == 0 &&
                stuSex == student.stuSex &&
                smoking == student.smoking &&
                Objects.equals(stuName, student.stuName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, stuName, stuScore, stuSex, smoking);
    }

    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", stuName='" + stuName + '\'' +
                ", stuScore=" + stuScore +
                ", stuSex=" + stuSex +
                ", smoking=" + smoking +
                '}';
    }
}
